netcdf4-python datetime casting#2181
Merged
bjlittle merged 2 commits intoSciTools:masterfrom Oct 12, 2016
Merged
Conversation
Member
Author
|
i think this should be evaluated against an unpinned matplotlib (thus an unpinned netcdf4-python), for python2 and python3, away from travis before the change is merged as it is in preparation for unpinning matplotlib |
Member
Author
I believe this supports that this change is valid, though it is very noisy due to outstanding python3 failures |
bjlittle
reviewed
Oct 12, 2016
lib/iris/fileformats/pp_rules.py
Outdated
| if t.minute == 0 and t.second == 0: | ||
| epoch_hours = round(epoch_hours) | ||
| return epoch_hours | ||
| return float(epoch_hours) |
Member
There was a problem hiding this comment.
@marqh A comment explaining the use of the cast would be useful here ...
bjlittle
reviewed
Oct 12, 2016
| # numpy.float64. The behaviour of round is to recast this to an | ||
| # int, which is not the desired behaviour for PP files. | ||
| # So, cast the answer to numpy.float_ to be safe. | ||
| epoch_hours = np.float_(epoch_hours_unit.date2num(t)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
possible fix for netcdf4-python behaviour change
in pp_rules date time calculations used to return floats, and still do in python2 but not in python3
iris/lib/iris/fileformats/pp_rules.py
Line 486 in 1c195e0
this manifested as a change in a doctest, but looks like a widespread issue where cubes are created using
hours_from_t1_to_t2and such like
iris/lib/iris/fileformats/pp_rules.py
Line 507 in 1c195e0
this work around may fix the problem